
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region OutletDAL
	public class OutletDAL : DBContext
	{
		public List<Outlet> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_OutletsSelectAll");
            return GetEntityList<Outlet>(cmd);
        }

        public Outlet GetById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_OutletSelect");
            cmd.AddParameter("@Id", id);
            return GetSingleEntity<Outlet>(cmd);
        }

		public List<Outlet> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_OutletSelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<Outlet>(cmd);
        }

        public Outlet Add(string paramName, string paramDescription, int paramWarehouseId, string paramAddress1,
                                 string paramAddress2, string paramAddress3, string paramFax, string paramTel, string paramPostCode,
                                 int paramCountryId, int paramCityId, int paramManager, string paramPOSLocationCode, string paramCreatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_OutletInsert");
            cmd.AddParameter("@Name", paramName);
            cmd.AddParameter("@Description", paramDescription);
            cmd.AddParameter("@WarehouseId", paramWarehouseId);
            cmd.AddParameter("@Address1", paramAddress1);
            cmd.AddParameter("@Address2", paramAddress2);
            cmd.AddParameter("@Address3", paramAddress3);
            cmd.AddParameter("@Fax", paramFax);
            cmd.AddParameter("@Tel", paramTel);
            cmd.AddParameter("@PostCode", paramPostCode);
            cmd.AddParameter("@CountryId", paramCountryId);
            cmd.AddParameter("@CityId", paramCityId);
            cmd.AddParameter("@Manager", paramManager);
            cmd.AddParameter("@POSLocationCode", paramPOSLocationCode);
            cmd.AddParameter("@CreatedBy", paramCreatedBy);
            return GetSingleEntity<Outlet>(cmd);
        }
		
        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_OutletDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public Outlet UpdateById(Guid paramId, string paramName, string paramDescription, int paramWarehouseId, string paramAddress1,
                                 string paramAddress2, string paramAddress3, string paramFax, string paramTel, string paramPostCode,
                                 int paramCountryId, int paramCityId, int paramManager, string paramPOSLocationCode, string paramUpdatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_OutletUpdate");
			cmd.AddParameter("@Id", paramId);
			cmd.AddParameter("@Name", paramName);
			cmd.AddParameter("@Description", paramDescription);
			cmd.AddParameter("@WarehouseId", paramWarehouseId);
			cmd.AddParameter("@Address1", paramAddress1);
			cmd.AddParameter("@Address2", paramAddress2);
			cmd.AddParameter("@Address3", paramAddress3);
			cmd.AddParameter("@Fax", paramFax);
			cmd.AddParameter("@Tel", paramTel);
			cmd.AddParameter("@PostCode", paramPostCode);
			cmd.AddParameter("@CountryId", paramCountryId);
			cmd.AddParameter("@CityId", paramCityId);
			cmd.AddParameter("@Manager", paramManager);
			cmd.AddParameter("@POSLocationCode", paramPOSLocationCode);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            return GetSingleEntity<Outlet>(cmd);
        }
		
	}
	#endregion
}
